<template>
	<div>
		<el-dialog title="审查自定义-肝损害剂量" :visible.sync="dialogVisibleJiLiang" width="1025px">
			<el-card class="box-card" style="margin-top:15px">
				<el-row :gutter="15">
					<div>
						<div class="orange_tip fl">
							小提示
						</div>
						<div class="orange_val">
							<p>1.一次性选择多个给药途径时，每个给药途径将与后面设置的范围分别生成一条维护数据，保存到自定义维护表中的记录为多条。</p>
							<p>2.请尽量把药品的剂量相关信息维护全面，特别是次剂量、给药频次。本程序只能对已维护的项目进行审查，未维护项目不能审查。</p>
						</div>
					</div>
					<el-form label-width="80px">
						<el-col :span="24" style="border-bottom:1px dashed #afafaf;margin-bottom:16px;"></el-col>
						<el-col :span="12">
							<el-form-item label="给药途径">
								<el-input v-model="dosingUnit_name"  :readonly="true"  size="mini" style="width:150px;"></el-input>
								<el-button type="primary" size="mini" @click="openSelect(1)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun(1)">清除</el-button>
							</el-form-item>
						</el-col>						
						<el-col :span="12">
							<el-form-item label="给药单位">
								<el-select v-model="submit.dosingUnit" size="small" placeholder="请选择">
									<el-option  label="ml" value="ml">
									</el-option>
								  </el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="计算方式">
								<el-select v-model="submit.calculation" size="small" placeholder="请选择">
									<el-option  label="常规" value="1"></el-option>
									<el-option  label="体重" value="2"></el-option>
									<el-option  label="体表" value="3"></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="肝损">
								<el-select v-model="submit.degree" size="small" placeholder="请选择">
									<el-option  label="肝功能不全" value="1"></el-option>
									<el-option  label="轻度肝损害" value="2"></el-option>
									<el-option  label="中度肝损害" value="3"></el-option>
									<el-option  label="重度肝损害" value="4"></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="年龄低值">
								<div class="dialogFirstRow">
									<el-select v-model="submit.age_low1" size="mini">
										<el-option label=">=" value="0"></el-option>
										<el-option label=">" value="1"></el-option>
									</el-select>
									<el-input v-model="submit.ageLow" v-only-number="{max:10000000000,min:0,precision:0}" size="mini" ></el-input>
									<el-select v-model="submit.age_low_unit1" size="mini">
										<el-option v-for="item in ageOptions" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="年龄高值">
								<div class="dialogFirstRow">
									<el-select v-model="submit.age_high1" size="mini">
										<el-option label="<=" value="0"></el-option>
										<el-option label="<" value="1"></el-option>
									</el-select>
									<el-input v-model="submit.ageH" v-only-number="{max:10000000000,min:0,precision:0}" size="mini"></el-input>
									<el-select v-model="submit.age_high_unit1" size="mini">
										<el-option v-for="item in ageOptions" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="疾病状态">
								<el-input v-model="diseaseName"  :readonly="true"  size="mini" style="width:150px;"></el-input>
								<el-button type="primary" size="mini" @click="openSelect(2)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun(2)">清除</el-button>
							</el-form-item>
						</el-col>
						<el-col :span="24" style="border-bottom:1px dashed #afafaf;margin-bottom:16px;"></el-col>
						<el-col :span="12">
							<el-form-item label="每次剂量">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.doseRangeL" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/ml</div>
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.doseRangeH" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日/ml</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="每日剂量">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.dailyDoseL" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/ml</div>
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.dailyDoseH" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日/ml</div>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="给药频次">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.dosingFrequencyLow" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/</div>
								<el-input v-model="submit.dosingFrequencyLowDay" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日</div>
								
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.dosingFrequencyHight" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/</div>
								<el-input v-model="submit.dosingFrequencyHightDay" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日</div>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="频次描述">
								<el-input v-model="submit.dosingFrequency" size="big"></el-input>
							</el-form-item>
						</el-col>
					</el-form>
				</el-row>
			</el-card>
			<span slot="footer" class="dialog-footer">
			    <el-button type="primary" @click="save">保 存</el-button>
			  </span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		name:"gshSetCard",
		data () {
			return {
				ageOptions:[
					{
					  value: '岁',
					  label: '岁'
					},
					{
					  value: '月',
					  label: '月'
					},
					{
					  value: '天',
					  label: '天'
					},
				],
				dosingUnit_name:"",
				diseaseName:"",
				submit:{
					drug_route:"",
					dosingUnit:"ml",
					calculation:"1",
					degree:"1",
					age_low1:"0",
					ageLow:"",
					age_low_unit1:"岁",
					age_high1:"0",
					ageH:"",
					age_high_unit1:"岁",
					diseaseStates:"",
					doseRangeL:"",
					doseRangeH: "",
					dailyDoseL:"",
					dailyDoseH:"",
					dosingFrequencyLow: "",
					dosingFrequencyLowDay:"",
					dosingFrequencyHight:"",
					dosingFrequencyHightDay:"",
					dosingFrequency:""
				},
				dialogVisibleJiLiang:false,
			}
		},
		props:{
			gyData:{
				type:Object
			},
			jbData:{
				type:Object
			},
			nowData:{
				type:Object
			}
		},
		watch:{
			gyData(val){
				this.dosingUnit_name=val.name;
				this.submit.drug_route=val.id
			},
			jbData(val){
				this.diseaseName=val.name;
				this.submit.diseaseStates=val.id;
			}
		},
		mounted () {
			console.log(this.nowData,11)
		},
		methods:{
			async save () {
				if(!this.submit.drug_route){
					this.$message({
					  message: "请输入择要设置的给药途径",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.ageLow){
					this.$message({
					  message: "请输入择要设置的年龄低值",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.ageH){
					this.$message({
					  message: "请输入择要设置的年龄高值",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.diseaseStates){
					this.$message({
					  message: "请输入择要设置的疾病状态",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				let newObj = {drugUniqueCode:this.nowData.drugUniqueCode};
				Object.assign(newObj,this.submit);
				let res = this.$custom.listliverDamageSave(newObj);
				if(res){
					this.$message({
					  message: res.msg,
					  type: res.code == 1?'success':'error',
					  duration:1500
					});
					if(res.code == 1){
						this.resetFun();
						this.dialogVisibleJiLiang=false;
						this.$emit("changeFun")
					}
				}
			},
			show () {
				this.dialogVisibleJiLiang = true;
			},
			clearFun(type){
				if(type == 1){
					this.dosingUnit_name="";
					this.submit.drug_route="";
				}else{
					this.diseaseName="";
					this.submit.diseaseStates="";
				}
			},
			openSelect (type) {
				if(type == 1){
					this.$emit("selectPop","给药途径",this.submit.drug_route);
				}else{
					this.$emit("selectPop","疾病",this.submit.diseaseStates);
				}
			},
			resetFun(){
				this.dosingUnit_name="";
				this.diseaseName="";
				this.submit={
					drug_route:"",
					dosingUnit:"ml",
					calculation:"1",
					degree:"1",
					age_low1:"0",
					ageLow:"",
					age_low_unit1:"岁",
					age_high1:"0",
					ageH:"",
					age_high_unit1:"岁",
					diseaseStates:"",
					doseRangeL:"",
					doseRangeH: "",
					dailyDoseL:"",
					dailyDoseH:"",
					dosingFrequencyLow: "",
					dosingFrequencyLowDay:"",
					dosingFrequencyHight:"",
					dosingFrequencyHightDay:"",
					dosingFrequency:""
				};
			}
		}
	}
</script>

<style lang="scss" scoped>
	.orange_tip{
		color:orange;
		width:80px;
		text-align:right;
		padding-right: 10px;
		line-height: 40px;
	}
	.orange_val{
		line-height:20px;
		margin-left:80px;
		margin-bottom:20px;
	}
	.el-card {
		margin-left: 3px;
	}
	.dialogFirstRow>>>.el-input {
		width: 70px;
		margin-right: 10px;
	}
	
	.el-form-item.s_selectbox>>>.el-form-item__content {
		width: 80%;
	}
	
	
	.demo-form-inline>>>.el-form-item {
		margin-bottom: 0px;
	}
	
	.dialogFirstRow>>>label {
		height:41px;
		display:inline-block;
	}
</style>